package com.play.game.mymvp.model;

import android.util.Log;

import com.google.gson.Gson;
import com.play.game.mymvp.Bean;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.List;

import okhttp3.Call;

/**
 * Created by 聪明一只哈 on 2018/4/11.
 * Time: 2018/4/11  12:40
 */

public class GrilModel implements IGrilModel {

    @Override
    public void loadGrild(final GrilOnLoadListener grilOnLoadListener) {
        OkHttpUtils
                .post()
                .url("http://www.kuaidi100.com/query?type=yuantong&postid=11111111111")
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.i("StringCallback", "onResponse: "+response);
                        Bean bean = new Gson().fromJson(response, Bean.class);

                        List<Bean.DataBean> data = bean.getData();
                        grilOnLoadListener.onComplete(data);

                    }
                });
    }

    public void initData() {
        OkHttpUtils
                .post()
                .url("http://www.kuaidi100.com/query?type=yuantong&postid=11111111111")
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.i("StringCallback", "onResponse: "+response);
                        Bean bean = new Gson().fromJson(response, Bean.class);

                        List<Bean.DataBean> data = bean.getData();
                       // MyAdapter myAdapter = new MyAdapter(MainActivity.this,data);
                        //lv.setAdapter(myAdapter);

                    }
                });

    }
}
